// 默认配置
var __PI_COLLECT_CONF = {
    "type":"web"
    ,"app":"pi-h5-monitor"
    ,"uri":"//{collectUrl}"
    ,"protocol": "{protocol}"
    ,"useCid":true
    ,"ent_id": ""
    ,"custom":{
        "task_id": "{task_id}"
    }
    ,"auto": true
    ,"keepCh": true
};

var entId = __PI_COLLECT_CONF.custom.task_id.split("-")[0];
entId = parseInt(entId, 10);
if (entId && !isNaN(entId)) {
    __PI_COLLECT_CONF.ent_id = entId;
}

var outConf = window._PI_COLLECT_CONF;

// 处理页面协议与统计协议不一致的问题
if (outConf && outConf.protocol) {
    __PI_COLLECT_CONF.protocol = outConf.protocol;
}

var pageProtocol = window.location.protocol;
pageProtocol = pageProtocol.replace(":", "");
if (
    pageProtocol === "https" &&
    __PI_COLLECT_CONF.protocol !== pageProtocol
){
    __PI_COLLECT_CONF.protocol = "https";
}
__PI_COLLECT_CONF.uri = __PI_COLLECT_CONF.protocol + ":" + __PI_COLLECT_CONF.uri;

// 是否自动打 pv
if (outConf && outConf.auto === false) {
    __PI_COLLECT_CONF.auto = false;
}

window.__PI_COLLECT_CONF = __PI_COLLECT_CONF;
